<?php
/**
 * Created by PhpStorm.
 * User: wangjie
 * Date: 2018/11/26
 * Time: 20:17
 */
namespace api\controllers;

use common\services\ColorService;

class ColorController extends BaseController
{
    /**
     * RBG 转 16进制
     * @return array
     */
    public function actionRgbToHex()
    {
        $rgb = trim($this->request->post('rgb', ''));

        $result = ColorService::RGBToHex($rgb);
        return $this->endReponse('0',['hex' => $result]);
    }

    /**
     * 16进制 转 RBG
     * @return array
     */
    public function actionHexToRgb()
    {
        $hex = trim($this->request->post('hex', ''));

        $result = ColorService::hexToRgb($hex);
        return $this->endReponse('0', $result);
    }

}